home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / bbs / cit_src_7H21.lha / verify.c < prev    next >
C/C++ Source or Header  |  1997-08-21  |  28KB  |  883 lines

  1. /*  Citadel Verify Database */
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include "ctdl.h"
  5. #include "c68door.h"
  6. extern CONFIG      cfg;            /* A buncha variables           */
  7. extern logBuffer   logBuf;         /* Pippul buffer                */
  8. extern FILE        *logfl;         /* log file descriptor          */
  9. extern LogTable    *logTab;
  10. extern int         thisLog;
  11. extern FILE            *netfl, *roomfl;
  12. extern NetBuffer   netBuf;
  13. extern NetTable    *netTab;
  14. extern rTable      *roomTab;         /* RAM index of rooms              */
  15. extern aRoom        roomBuf;         /* room buffer    */
  16. extern EVENT       *EventTab;        /* Events Table */
  17. extern int          TopFloor;        /* limit on floor */
  18. extern struct floor  *FloorTab;
  19.  
  20. #define max(x,y)        ((x) > (y) ? (x) : (y))
  21.  
  22. void Process_Msg(MessageBuffer  *msg);
  23. void Do_Room_Stats(long total);
  24. void Do_Message(MessageBuffer  *);
  25. void Verify_Messages(void);
  26. int MsgLen(MessageBuffer  *);
  27. void ShowHash(void);
  28. void showlog(int);
  29. char *LastOn(long lastdate, char s);
  30. void Do_Boolean(char *,short,short);
  31. void Verify_Config(void);
  32. void Verify_Log(void);
  33. void Verify_Room(void);
  34. void Verify_Floor(void);
  35. void Verify_Events(void);
  36. void crashout(char *);
  37. void Check_codeBuf(char *,long,short);
  38. void Check_Shared(void);
  39. void Do_nflags(struct nflags *);
  40. void Do_Multi_Net_Data(MULTI_NET_DATA);
  41. void Do_Shared_Room(SharedRoom *);
  42. void Do_Door_Data(void);
  43. void Do_Net_Data(void);
  44. void Do_NetBuf_Data(int slot);
  45. void Process_Other_Room_Data(int Index);
  46.  
  47. short Vflag;   /* TRUE - Verbose output( config) */
  48. short Lflag;   /* TRUE - Verbose output( user log) */
  49. short Nflag;   /* TRUE - Verbose output( ctdlnet.sys ) */
  50. short Rflag;   /* TRUE - Verbose output( Room data ) */
  51. short Dflag;   /* TRUE - Verbose output(Doors data ) */
  52. short Mflag;   /* TRUE - Verbose output(Message data ) */
  53. short Eflag;   /* TRUE - Process Event data */
  54. short Fflag;   /* TRUE - Process Floor Table */
  55. short sfflag;  /* TRUE - Message Dump is Multiple line */
  56.  
  57. char MControl;    /* selective dump control */
  58. int  mPrintf(char *format, ...) {return 0; }  /* stub to quiet the linker */
  59.  
  60.  
  61. void crashout(str)
  62. char *str;
  63.   {
  64.   printf(str);
  65.   exit(10);
  66.  
  67.   }
  68. int  main(int,char **);
  69. int  main(argc,argv)
  70. int  argc;
  71. char **argv;
  72.   {
  73.   SYS_FILE fn;
  74.   /* Process CONFIG  */
  75.   cfg.weAre = UTILITY;
  76.   sfflag = TRUE;
  77.   if( argc > 1 )
  78.     {
  79.     Fflag = Eflag = Dflag = Rflag = Vflag = Lflag = Mflag = Nflag = FALSE;
  80.     MControl = '\0';
  81.     }
  82.   else Fflag =  Eflag = Dflag = Rflag = Vflag = Lflag = Mflag = Nflag = TRUE;  /* default is all */
  83.   printf("Citadel Verify Database Utility Version %s\n", VERSION_NAME);
  84.   for( ;--argc>0; )
  85.     {
  86.     if( *argv[argc] == '-' )
  87.       {
  88.       switch ( argv[argc][1])
  89.         {
  90.         case 'a' :
  91.         case 'A' : Fflag = Mflag = Eflag = Dflag = Lflag = Vflag = Rflag = Nflag = TRUE;break;
  92.         case 'd' :
  93.         case 'D' : Dflag = TRUE;break;
  94.         case 'e' :
  95.         case 'E' : Eflag = TRUE;break;
  96.         case 'f' :
  97.         case 'F' : Fflag = TRUE;break;
  98.         case 'l' :
  99.         case 'L' : Lflag = TRUE;break;
  100.         case 'm' :
  101.         case 'M' : Mflag = TRUE;MControl = argv[argc][2];break;
  102.         case 'n' :
  103.         case 'N' : Nflag = TRUE;break;
  104.         case 'r' :
  105.         case 'R' : Rflag = TRUE;break;
  106.         case 'v' :
  107.         case 'V' : Vflag = TRUE;break;
  108.         case 's' :
  109.         case 'S' : sfflag = FALSE; break;
  110.         default:
  111.         printf("illegal option ignored:%s\n",argv[argc]);
  112.         printf(" Valid options are:\n");
  113.         printf("   -L User Log data  -V config data\n");
  114.         printf("   -R room data      -M Messages data\n");
  115.         printf("   -N net data       -E Event data        -S one line message data\n");
  116.         printf("   -D Door Data      -F Floor data        -A All of the Above\n");
  117.         };
  118.  
  119.       };
  120.  
  121.     };
  122.   if (!readSysTab(FALSE, TRUE)) exit(100);
  123.   Verify_Config();             /* Verify the data in the main database */
  124.   /* Process the User Log */
  125.   sprintf(fn, "%sctdllog.sys", &cfg.logArea);
  126.   if ((logfl = fopen(fn, "rb")) == NULL)
  127.     {
  128.     printf("Can't open the Citadel log!\n");
  129.     exit(1);
  130.  
  131.     }
  132.   initLogBuf(&logBuf);
  133.   Verify_Log();
  134.   if( cfg.BoolFlags.netParticipant )
  135.     {
  136.     /* process network information */
  137.     sprintf(fn, "%sctdlnet.sys", &cfg.netArea);
  138.     openFile(fn, &netfl);
  139.     initNetBuf(&netBuf);
  140.  
  141.     };
  142.   /* open room file */
  143.   sprintf(fn, "%sctdlroom.sys", &cfg.roomArea);
  144.   openFile(fn, &roomfl);
  145.   initRoomBuf(&roomBuf);
  146.   Verify_Room();
  147.   fclose(roomfl);
  148.   /* close room file */
  149.   Verify_Floor();
  150.   Do_Door_Data();
  151.   Verify_Messages();    /* process the messages */
  152.   Verify_Events();      /* Event Data processing */
  153.   return 0;
  154.   }
  155.  
  156. struct  namelist
  157.   {
  158.   char *GenName;
  159.   int  GenVal;
  160.  
  161.   };
  162.  
  163. typedef struct namelist GenList;
  164.  
  165.   /***  INDENT-OFF ***/
  166. #define MAXDAYS  (8)
  167. #define MAXTYPES (3)
  168.  
  169. static GenList EvnDays[MAXDAYS] =
  170.   {
  171.     {    "Sun", SUNDAYS     },    {    "Mon", MONDAYS     },
  172.     {    "Tue", TUESDAYS    },    {    "Wed", WEDNESDAYS  },
  173.     {    "Thu", THURSDAYS   },    {    "Fri", FRIDAYS     },
  174.     {    "Sat", SATURDAYS   },    {    "All", ALL_DAYS    }
  175.   };
  176.  
  177. static GenList EvnTypes[MAXTYPES] =
  178.   {
  179.     {    "preempt",     TYPREEMPT  },    {    "non-preempt", TYNON      },
  180.     {    "quiet",       TYQUIET    }
  181.   };
  182.  
  183.  
  184. static GenList EvCls[EVENT_CLASS_COUNT] =
  185.   {
  186.     {    "network",             CLNET        },
  187.     {    "external",            CLEXTERN     },
  188.     {    "relative",            CLREL        },
  189.     {    "dl-time",             CL_DL_TIME   },
  190.     {    "anytime-net",         CL_ANYTIME_NET   },
  191.     {    "door-limit",          CL_DOOR_TIME },
  192.     {    "autodoor",            CL_AUTODOOR  },
  193.     {    "chat-on",             CL_CHAT_ON   },
  194.     {    "chat-off",            CL_CHAT_OFF  },
  195.     {    "redirect",            CL_REDIRECT  },
  196.     {    "newusers-allowed",    CL_NEWUSERS_ALLOWED   },
  197.     {    "newusers-disallowed", CL_NEWUSERS_DISALLOWED   },
  198.     {    "until-done-net",      CL_UNTIL_NET  },
  199.     {    "netcache",            CL_NETCACHE   },
  200.     };
  201.  
  202.  /**  INDENT-ON **/
  203. char *fake = "Unknown nnn  ";
  204.  
  205. char *Look_Up(int value,  GenList list[], int limit )
  206.  {
  207.  int i;
  208.  for( i=0; i<limit; i++) if( list[i].GenVal == value ) return list[i].GenName;
  209.  sprintf(&fake[8],"%3d",value);
  210.  return fake;
  211.  }
  212.  
  213. void Verify_Floor()
  214.   {
  215.   int rover;
  216.   for ( rover=0; rover < TopFloor; rover++)
  217.     {
  218.     if( FloorTab[rover].FlInuse )
  219.       {
  220.       printf(" Floor slot[%d] in use  Name:%20s Moderator:%s\n",
  221.         rover, FloorTab[rover].FlName,
  222.        ( FloorTab[rover].FlModerator[0] != '\0' ? FloorTab[rover].FlModerator : "No Moderator") );
  223.       }
  224.     else  printf(" Floor slot[%d] not in use\n",rover);
  225.  
  226.     };
  227.   }
  228.  
  229. void Verify_Events()
  230.   {
  231.   int i,j;
  232.   int hrs,mins;
  233.   long minutes;
  234.   int day;
  235.   if( !Eflag )return;  /* exit if not requested */
  236.   printf("\n\nThere are %d events\n",cfg.EvNumber);
  237.   for( i=0; i< cfg.EvNumber; i++)
  238.     {
  239.     hrs = EventTab[i].EvDur / 60;
  240.     mins= EventTab[i].EvDur % 60;
  241.     printf("\nEvent Number: %d Duration:%d(%d:%02.2d)   ",i,EventTab[i].EvDur, hrs, mins);
  242.     printf("Event Type: %s\n", Look_Up(EventTab[i].EvType,EvnTypes,MAXTYPES) );
  243.     printf("Event Warning:%s\n",( cfg.codeBuf+EventTab[i].EvWarn) );
  244.     printf("Event Class:%s   ",Look_Up(EventTab[i].EvClass,EvCls,EVENT_CLASS_COUNT) );
  245.     printf("Event EvExitVal:%08.8lX :",EventTab[i].EvExitVal);
  246.     for (j = 0; j < 32; j++)
  247.       {
  248.       if (( 1l << j ) & EventTab[i].EvExitVal) printf("%d ", j + 1);
  249.       };
  250.     printf("\n");
  251.     hrs = EventTab[i].EvDur / 60;
  252.     mins= EventTab[i].EvDur % 60;
  253.     printf("Event Minutes: %d(%d:%02.2d)\n",EventTab[i].EvMinutes, hrs, mins);
  254.     day = 1;
  255.     minutes = EventTab[i].EvMinutes;
  256.     while( minutes >= 1440)
  257.       {
  258.       day <<= 1;
  259.       minutes -= 1440;
  260.       };
  261.     hrs = minutes / 60;
  262.     mins= minutes % 60;
  263.     printf("Event Day: %s  Start Time:%ld(%d:%02.2d)\n",Look_Up(day,EvnDays, MAXDAYS), minutes, hrs, mins);
  264.     switch (EventTab[i].EvClass)
  265.       {
  266.       case CL_ANYTIME_NET:
  267.         printf("Anytime DeadTime: %ld  Anytime Duration: %d\n",
  268.         EventTab[i].vars.Anytime.EvDeadTime, EventTab[i].vars.Anytime.EvAnyDur);
  269.         break;
  270.       case CL_AUTODOOR:
  271.         printf("AutoDoor for User:%s\n", EventTab[i].vars.EvUserName);
  272.         break;
  273.       case CL_REDIRECT:
  274.         printf("Redirect incoming: System:%s\n"
  275.         ,EventTab[i].vars.Redirect.EvSystem);
  276.         printf("Directory:%s Filename:%s\n",
  277.         (EventTab[i].vars.Redirect.EvHomeDir + cfg.codeBuf)
  278.         ,EventTab[i].vars.Redirect.EvFilename);
  279.         break;
  280.       };
  281.     };
  282.   }
  283.  
  284.  
  285.  
  286. void Verify_Room()
  287.   {
  288.   short Index;
  289.   for (Index = 0; Index < MAXROOMS; Index++)
  290.     {
  291.     if( Rflag )printf("\nRoom Slot #%d:",Index);
  292.     if(   roomTab[Index].rtflags.INUSE )
  293.       {
  294.       if( Index < 3 )
  295.         {
  296.         if( roomTab[Index].rtFlIndex != 0 )
  297.           {
  298.           printf("\nInitial Room not on Base Floor!\n");
  299.  
  300.           };
  301.  
  302.         };
  303.       if( Rflag )
  304.         {
  305.         printf("%20s Last Message:%ld Last Netted message:%ld\n",
  306.         roomTab[Index].rtname,roomTab[Index].rtlastMessage,roomTab[Index].rtlastNet);
  307.         printf("Floor Index:%d\n", roomTab[Index].rtFlIndex);
  308.         if( Index != MAILROOM)Process_Other_Room_Data(Index);
  309.         };
  310.       }
  311.     else if( Rflag )printf(" Not in use at this time\n");
  312.  
  313.     };
  314.   if( Nflag )Check_Shared();
  315.  
  316.   }
  317. void Do_Net_Data()
  318.   {
  319.   printf("\nNode Name:%-22s  Node Id: %s\n",netBuf.netName, netBuf.netId);
  320.   printf("Short Name:%c%c%c  Passwords: Our(%s) Their(%s)\n",
  321.   (isprint(netBuf.nbShort[0]) ? netBuf.nbShort[0] : '*'),
  322.   (isprint(netBuf.nbShort[1]) ? netBuf.nbShort[1] : '*'),
  323.   (isprint(netBuf.nbShort[2]) ? netBuf.nbShort[2] : '*'),
  324.   netBuf.OurPwd, netBuf.TheirPwd);
  325.   printf("baudCode:%c nbGen: %c access:%s\n",
  326.   netBuf.baudCode, netBuf.nbGen, netBuf.access);
  327.   printf("nbRoute:%d nbRouteGen:%d nbHiRouteInd: %d nbLastConnect: %x\n",
  328.   netBuf.nbRoute, netBuf.nbRouteGen, netBuf.nbHiRouteInd, netBuf.nbLastConnect);
  329.   }
  330.  
  331. void Check_Shared()
  332.   {
  333.   short netrover;
  334.   for( netrover=0; netrover < cfg.netSize; netrover++)
  335.     {
  336.     getNet(netrover,&netBuf);
  337.     Do_NetBuf_Data(netrover);
  338.     printf("\nnetTab[%d]:",netrover);
  339.     if( netTab[netrover].ntflags.in_use )
  340.       {
  341.       printf(" In use\n");
  342.       printf(" ntnmhash: %d  ntidhash: %d  Short name:%c%c%c Generation: %d\n",
  343.       netTab[netrover].ntnmhash,netTab[netrover].ntidhash,
  344.       (isprint(netTab[netrover].ntShort[0]) ? netTab[netrover].ntShort[0] : '*'),
  345.       (isprint(netTab[netrover].ntShort[1]) ? netTab[netrover].ntShort[1] : '*'),
  346.       (isprint(netTab[netrover].ntShort[2]) ? netTab[netrover].ntShort[2] : '*'),
  347.       netTab[netrover].ntGen);
  348.       Do_nflags(&netTab[netrover].ntflags);
  349.       Do_Multi_Net_Data(netTab[netrover].ntMemberNets);
  350.       Do_Shared_Room(netTab[netrover].netTRooms);
  351.       Do_Net_Data();
  352.       }
  353.     else
  354.       {
  355.       printf("Not in use\n");
  356.  
  357.       };
  358.  
  359.     };
  360.  
  361.   }
  362. void Do_nflags(ntflags)
  363. struct nflags *ntflags;
  364.   {
  365.   Do_Boolean("normal_mail   ",ntflags->normal_mail,FALSE);
  366.   Do_Boolean("in_use        ",ntflags->in_use,FALSE);
  367.   Do_Boolean("room_files    ",ntflags->room_files,TRUE);
  368.   Do_Boolean("local         ",ntflags->local,FALSE);
  369.   Do_Boolean("spine         ",ntflags->spine,FALSE);
  370.   Do_Boolean("send_files    ",ntflags->send_files,TRUE);
  371.   Do_Boolean("is_spine      ",ntflags->is_spine,FALSE);
  372.   Do_Boolean("OtherNet      ",ntflags->OtherNet,FALSE);
  373.   Do_Boolean("HasRouted     ",ntflags->HasRouted,TRUE);
  374.   Do_Boolean("RouteFor      ",ntflags->RouteFor,FALSE);
  375.   Do_Boolean("RouteTo       ",ntflags->RouteTo,FALSE);
  376.   Do_Boolean("Stadel        ",ntflags->Stadel,TRUE);
  377.   Do_Boolean("RouteLock     ",ntflags->RouteLock,FALSE);
  378.   Do_Boolean("ExternalDialer",ntflags->ExternalDialer,FALSE);
  379.   Do_Boolean("NoDL          ",ntflags->NoDL,TRUE);
  380.   Do_Boolean("MassTransfer  ",ntflags->MassTransfer,FALSE);
  381.   Do_Boolean("Zip           ",ntflags->Zip,FALSE);
  382.   Do_Boolean("Zoo           ",ntflags->Zoo,TRUE);
  383.   Do_Boolean("Arc           ",ntflags->Arc,FALSE);
  384.   Do_Boolean("Lha           ",ntflags->Lha,FALSE);
  385.  
  386.   }
  387. void Do_Multi_Net_Data(MN)
  388. MULTI_NET_DATA MN;
  389.   {
  390.   short i;
  391.   printf(" Member of Nets:");
  392.   for(i=0; i<MAX_NET-1;i++) if( ((1<<i) & MN) !=0 )printf(" %d",i+1);
  393.   printf("\n");
  394.   if( (MN & 0x80000000) != 0)printf("Priority Mail\n");
  395.  
  396.   }
  397. void Do_Shared_Room(nRms)
  398. SharedRoom *nRms;
  399.   {
  400.   int slot;
  401.   for(slot = 0; slot < SHARED_ROOMS; slot++)
  402.     {
  403.     if( (nRms->srgen & 0x8000) )
  404.       {
  405.       printf(" \nSR[%d]:  lM:%ld  Mode:",slot,  nRms->lastMess);
  406.       switch (CGetMode(nRms->mode))
  407.         {
  408.         case            PEON: printf("Peon            "); break;
  409.         case        REG_HOST: printf("Reg Host        "); break;
  410.         case        BACKBONE: printf("Backbone        "); break;
  411.         case   PASS_BACKBONE: printf("Passive Backbone"); break;
  412.         case ACTIVE_BACKBONE: printf("Active Backbone "); break;
  413.         default:              printf("Unknown");
  414.         };
  415.       printf("  F:%s srgen:%x srslot: %d",
  416.       (GetFA(nRms->mode) != 0 ? "YES":"NO "),nRms->srgen,nRms->srslot);
  417.       };
  418.       nRms++;
  419.     };
  420.   }
  421. void Check_codeBuf(str,data,control)
  422. char *str;
  423. long data;
  424. short control;   /* TRUE - Newline if verbose operation */
  425.   {
  426.   if( data >= MAXCODE )
  427.     {
  428.     printf("\nInvalid values(%d) for offset:%s\n",data,str);
  429.  
  430.     }
  431.   else
  432.     {
  433.     if(Vflag)
  434.       {
  435.       char *d;
  436.       d = &cfg.codeBuf[0];
  437.       printf("%-20s(%ld):%s%c",str,data,
  438.       (data == 0 ? "Undefined" : &d[data]),(control ? '\n':' '));
  439.  
  440.       };
  441.  
  442.     };
  443.  
  444.   }
  445. void Verify_Config()
  446.   {
  447.   short i;
  448.   if( Vflag )
  449.     {
  450.     printf("\nmaxMSector:%d ",cfg.maxMSector);
  451.     printf("Message Old::%ld New:%ld\n",cfg.oldest,cfg.newest);
  452.  
  453.     };
  454.   Check_codeBuf("Node Name",  cfg.nodeName,TRUE);
  455.   Check_codeBuf("Node Id",    cfg.nodeId,FALSE);
  456.   Check_codeBuf("Node Domain",cfg.nodeDomain,TRUE);
  457.   Check_codeBuf("Node Title", cfg.nodeTitle,TRUE);
  458.   Check_codeBuf("Main Floor", cfg.MainFloor,FALSE);
  459.   Check_codeBuf("Base Room",  cfg.bRoom, TRUE);
  460.   for(i=0;i<7;i++)
  461.     {
  462.     Check_codeBuf("Dial Prefix",cfg.DialPrefixes[i],TRUE);
  463.  
  464.     };
  465.   Check_codeBuf("Dial Suffix",cfg.netSuffix,TRUE);
  466.   if( Vflag )
  467.     {
  468.     printf("Max File:%d Area Size: %d receptArea:%s\n",
  469.     cfg.maxFileSize, cfg.sizeArea, &cfg.receptArea);
  470.     printf("Sysop:%s CryptSeed:%d InitColumns:%d LoginAttempts:%d Audit: %d(%s)\n",
  471.     cfg.SysopName,cfg.cryptSeed,cfg.InitColumns,cfg.LoginAttempts,
  472.     cfg.Audit,( cfg.Audit == 0 ? "None":(cfg.Audit == 1? "Normal":"No Net") ) );
  473.     printf("  homeArea:%s\n",&cfg.homeArea);
  474.     printf("   msgArea:%s\n",&cfg.msgArea);
  475.     printf("  msg2Area:%s\n",&cfg.msg2Area);
  476.     printf("   logArea:%s\n",&cfg.logArea);
  477.     printf("  roomArea:%s\n",&cfg.roomArea);
  478.     printf("   netArea:%s\n",&cfg.netArea);
  479.     printf("domainArea:%s\n",&cfg.domainArea);
  480.     printf(" auditArea:%s\n",&cfg.auditArea);
  481.     printf(" floorArea:%s\n",&cfg.floorArea);
  482.     printf("  holdArea:%s\n",&cfg.holdArea);
  483.     printf("sysBaud:%d netSiz:%d DomainHandlers:%d\n"
  484.     ,cfg.sysBaud,cfg.netSize,cfg.DomainHandlers);
  485.  
  486.     };
  487.   Check_codeBuf("Mail Hub",cfg.MailHub,TRUE);
  488.   if( Vflag )
  489.     {
  490.     printf("Domain display Format:%s\n",&cfg.DomainDisplay[0]);
  491.     printf("EvNumber:%d weAre:%d paramVers:%d\n",cfg.EvNumber,cfg.weAre,cfg.paramVers);
  492.     printf("MaxLog size:%d ",cfg.MAXLOGTAB);
  493.     printf("Mail  Slots:%d ",cfg.MailSlots);
  494.     printf("Msgs Per room:%d\n",cfg.MsgsPerrm);
  495.     printf("Max Rooms:%d ",cfg.MaxRooms);
  496.     printf("Shared Rooms:%d\n",cfg.SharedRooms);
  497.     printf("Next msg slot: %d/%d Anon Mail Max Length:%d\n",
  498.     cfg.catChar,cfg.catSector,cfg.AnonMailLength);
  499.     printf("Log entries are %d in size\n",cfg.sizeLTentry);
  500.     printf("Console Timeout:%d\n",cfg.ConTimeOut);
  501.     printf("Sysop Archive:%s\n",cfg.SysopArchive);
  502.     Do_Boolean("HoldOnLost    ", cfg.BoolFlags.HoldOnLost    ,FALSE);
  503.     Do_Boolean("mirror        ", cfg.BoolFlags.mirror        ,FALSE);
  504.     Do_Boolean("unlogEnterOk  ", cfg.BoolFlags.unlogEnterOk  ,TRUE);
  505.     Do_Boolean("unlogReadOk   ", cfg.BoolFlags.unlogReadOk   ,FALSE);
  506.     Do_Boolean("nonAideRoomOk ", cfg.BoolFlags.nonAideRoomOk ,FALSE);
  507.     Do_Boolean("noMail        ", cfg.BoolFlags.noMail        ,TRUE);
  508.     Do_Boolean("noChat        ", cfg.BoolFlags.noChat        ,FALSE);
  509.     Do_Boolean("netParticipant", cfg.BoolFlags.netParticipant,FALSE);
  510.     Do_Boolean("aideSeeAll    ", cfg.BoolFlags.aideSeeAll    ,TRUE);
  511.     Do_Boolean("debug         ", cfg.BoolFlags.debug         ,FALSE);
  512.     Do_Boolean("NetDft        ", cfg.BoolFlags.NetDft        ,FALSE);
  513.     Do_Boolean("SysopEditor   ", cfg.BoolFlags.SysopEditor   ,TRUE);
  514.     Do_Boolean("IsDoor        ", cfg.BoolFlags.IsDoor        ,FALSE);
  515.     Do_Boolean("RouteMail     ", cfg.BoolFlags.RouteMail     ,FALSE);
  516.     Do_Boolean("DoorDft       ", cfg.BoolFlags.DoorDft       ,TRUE);
  517.     Do_Boolean("AnonSessions  ", cfg.BoolFlags.AnonSessions  ,FALSE);
  518.     Do_Boolean("DL_Default    ", cfg.BoolFlags.DL_Default    ,FALSE);
  519.     Do_Boolean("NetScanBad    ", cfg.BoolFlags.NetScanBad    ,TRUE);
  520.     printf("SysOp Editor:%s\n",cfg.DepData.Editor);
  521.     printf("SysOp Editor Area:%s\n",cfg.DepData.EditArea);
  522.     printf("Sysdependant Modem:%s\n",cfg.DepData.ModemSetup);
  523.     printf("Sysdependant Modem Init:%s\n",cfg.DepData.HiSpeedInit);
  524.     printf("Sysdependant Modem Unit %d Device:%s\n"
  525.     , cfg.DepData.UnitNumber, cfg.DepData.DevName);
  526.     printf("Sysdependant clock:%d\n",cfg.DepData.Clock);
  527.     printf("Sysdependant Lockport:%d\n",cfg.DepData.LockPort);
  528.     printf("Sysdependant width: %d Height: %d Depth: %d\n",
  529.     cfg.DepData.ScreenWidth,cfg.DepData.ScreenHeight,cfg.DepData.ScreenDepth);
  530.     printf("Sysdependant Colors:%d %d\n",cfg.DepData.Color0, cfg.DepData.Color1);
  531.  
  532.     };
  533.  
  534.   }
  535. void Do_Boolean(str,flag,control)
  536. char *str;
  537. short flag,control;
  538.   {
  539.   printf("%s: %s%c",str,(flag!=0 ? "Yes  " : "No   "),(control ? '\n' : ' ') );
  540.  
  541.   }
  542. void Verify_Log()
  543.   {
  544.   short i;
  545.   initLogBuf(&logBuf);
  546.   for ( i = 0; i < cfg.MAXLOGTAB; i++ )
  547.     {
  548.     getLog(&logBuf,i);
  549.     if( Lflag )printf("\nlog:%-4d",i);
  550.     if (logBuf.lbflags.L_INUSE)
  551.       {
  552.       showlog(i);
  553.       if( logBuf.lbwidth < 40 || logBuf.lbwidth > 132 )
  554.         {
  555.         printf("Log:%d,  %s terminal width = %d\n",i,logBuf.lbname,logBuf.lbwidth);
  556.  
  557.         };
  558.       if( logBuf.lbnulls > 50 )
  559.         {
  560.         printf("Log:%d,  %s terminal nulls = %d\n",i,logBuf.lbname,logBuf.lbnulls);
  561.  
  562.         };
  563.       if( logBuf.credit < 0 || logBuf.credit > 1000)
  564.         {
  565.         printf("Log:%d,  %s Long Distance credits = %d\n",i,logBuf.lbname,logBuf.credit);
  566.  
  567.         };
  568.  
  569.       }
  570.     else
  571.       {
  572.       if( Lflag )printf(" Not in use at this time\n");
  573.  
  574.       };
  575.  
  576.     };
  577.  
  578.   }
  579. void showlog(i)
  580. int i;
  581.   {
  582.   if( Lflag )
  583.     {
  584.     printf("%4d: %-20s",i,logBuf.lbname);
  585.     printf("%-20s",logBuf.lbpw);
  586.     ShowHash();
  587.     printf(" %d col. Last Call:%s\n",logBuf.lbwidth, LastOn(logBuf.lblaston, TRUE));
  588.     Do_Boolean("AIDE Status       ",logBuf.lbflags.AIDE      ,FALSE);
  589.     Do_Boolean("Expert User       ",logBuf.lbflags.EXPERT    ,FALSE);
  590.     Do_Boolean("Network Privilege ",logBuf.lbflags.NET_PRIVS ,TRUE);
  591.     Do_Boolean("Door Privilege    ",logBuf.lbflags.DOOR_PRIVS,FALSE);
  592.     Do_Boolean("Download Privilege",logBuf.lbflags.DL_PRIVS  ,FALSE);
  593.     Do_Boolean("Permanent Account ",logBuf.lbflags.PERMANENT ,TRUE);
  594.     Do_Boolean("Floor mode        ",logBuf.lbflags.FLOORS    ,FALSE);
  595.     Do_Boolean("TWIT User         ",logBuf.lbflags.TWIT      ,FALSE);
  596.     Do_Boolean("RUGGIE User       ",logBuf.lbflags.RUGGIE    ,TRUE);
  597.     Do_Boolean("Active Account    ",logBuf.lbflags.L_INUSE   ,FALSE);
  598.     Do_Boolean("LF FLAG           ",logBuf.lbflags.LFMASK    ,FALSE);
  599.     Do_Boolean("OLD STYLE         ",logBuf.lbflags.OLDTOO    ,TRUE);
  600.     Do_Boolean("HALF DUPLEX       ",logBuf.lbflags.HALF_DUP  ,FALSE);
  601.     Do_Boolean("ALT. Read Messages",logBuf.lbflags.ALT_RE    ,FALSE);
  602.     Do_Boolean("Room Name Prompt  ",logBuf.lbflags.NoPrompt  ,TRUE);
  603.  
  604.     };
  605.  
  606.   }
  607. void ShowHash()
  608.   {
  609.   int i;
  610.   for (i = 0; i < cfg.MAXLOGTAB; i++)
  611.   if (logTab[i].ltlogSlot == thisLog)
  612.     {
  613.     printf("ltab=%02d, hash=%02d\n ", logTab[i].ltpwhash, hash(logBuf.lbpw));
  614.  
  615.     }
  616.  
  617.   }
  618. void Do_Door_Data()
  619.   {
  620.   FILE        *fd;
  621.   SYS_FILE    name;
  622.   DoorData    DoorInfo;
  623.   extern char *READ_ANY;
  624.   short flag;
  625.   makeSysName(name, DOOR_DATA, &cfg.roomArea);
  626.   if ((fd = safeopen(name, READ_ANY)) == NULL)
  627.     {
  628.     if( Dflag )printf("No doors appear to be available.\n ");
  629.     return;
  630.  
  631.     };
  632.   /* process each door */
  633.   while ( fread((char *)&DoorInfo, sizeof DoorInfo, 1, fd) != 0)
  634.     {
  635.     if( Dflag)
  636.       {
  637.       printf("\nDoor Code:%s Program:%s Room:%s\n"
  638.       ,DoorInfo.entrycode,DoorInfo.program,DoorInfo.RoomName);
  639.       printf("Parameters:%s\n",DoorInfo.parameters);
  640.       printf("Description:%s\n",DoorInfo.description);
  641.       printf("Location:%s TimeLimit:%d\n",DoorInfo.location,DoorInfo.TimeLimit);
  642.       flag = (DOOR_AIDE    & DoorInfo.flags) ? 1:0;
  643.       Do_Boolean("   AIDE",flag,FALSE);
  644.       flag = (DOOR_SYSOP   & DoorInfo.flags) ? 1:0;
  645.       Do_Boolean("  SYSOP",flag,FALSE);
  646.       flag = (DOOR_CON     & DoorInfo.flags) ? 1:0;
  647.       Do_Boolean("Console",flag,TRUE);
  648.       flag = (DOOR_MODEM   & DoorInfo.flags) ? 1:0;
  649.       Do_Boolean("  Modem",flag,FALSE);
  650.       flag = (DOOR_AUTO    & DoorInfo.flags) ? 1:0;
  651.       Do_Boolean("   Auto",flag,FALSE);
  652.       flag = (DOOR_NEWUSER & DoorInfo.flags) ? 1:0;
  653.       Do_Boolean("NewUser",flag,TRUE);
  654.       printf("\n");
  655.  
  656.       };
  657.  
  658.     };
  659.  
  660.   }
  661. /*
  662. * doMessages()
  663. *
  664. * This function loops thru the msg file until finished.  It accumulates
  665. * statistics, etc.
  666. */
  667. extern MessageBuffer  msgBuf; /* The -sole- message buffer      */
  668. extern FILE *msgfl, *msgfl2;
  669.  
  670. struct counts
  671.   {
  672.   struct counts *next;
  673.   char name[20];    /* room name */
  674.   long  messages;   /* number of messages in the room */
  675.   long bytes;       /* total space the message uses */
  676.  
  677.   };
  678. struct counts *Header = NULL;
  679.  
  680. void Process_Msg(MessageBuffer  *msg)
  681.   {
  682.   struct counts *ptr;
  683. /*
  684. ** User names Statistics
  685. */
  686.   if( Header == NULL )
  687.     {
  688.     Header = ptr = malloc(sizeof(struct counts));
  689.     strcpy(ptr->name, msg->mbauth);
  690.     ptr->messages = 0;
  691.     ptr->bytes    = 0;
  692.     ptr->next     = NULL;
  693.     }
  694.   else
  695.     {
  696.     ptr = Header;
  697.     while( ptr != NULL )
  698.       {
  699.       if( strcmp(msg->mbauth,ptr->name)== 0 )break;
  700.       ptr = ptr->next;
  701.       };
  702.     if( ptr == NULL )
  703.       {
  704.       ptr = malloc(sizeof(struct counts));
  705.       strcpy(ptr->name, msg->mbauth);
  706.       ptr->messages = 0;
  707.       ptr->bytes    = 0;
  708.       ptr->next     = Header;
  709.       Header        = ptr;
  710.       };
  711.     };
  712.  
  713.   ptr->messages++;
  714.   ptr->bytes += MsgLen(msg);
  715. /*
  716. ** Room Statistics
  717. */
  718.   ptr = Header;
  719.   while( ptr != NULL )
  720.     {
  721.     if( strcmp(msg->mbroom,ptr->name)== 0 )break;
  722.     ptr = ptr->next;
  723.     };
  724.   if( ptr == NULL )
  725.     {
  726.     ptr = malloc(sizeof(struct counts));
  727.     strcpy(ptr->name, msg->mbroom);
  728.     ptr->messages = 0;
  729.     ptr->bytes    = 0;
  730.     ptr->next     = Header;
  731.     Header        = ptr;
  732.     };
  733.   ptr->messages++;
  734.   ptr->bytes += MsgLen(msg);
  735.  
  736.   }
  737.  
  738. void Do_Room_Stats(long total)
  739.   {
  740.   struct counts *ptr;
  741.   printf("Total of %ld messages\n",total);
  742.   ptr = Header;
  743.   while( ptr )
  744.     {
  745.     if( ptr->messages <= 0)ptr->messages = 1;
  746.     printf("Name:%20s Messages:%10ld Bytes:%10ld Aver:%10ld\n"
  747.     ,ptr->name,ptr->messages, ptr->bytes, ptr->bytes/ptr->messages);
  748.     ptr = ptr->next;
  749.     };
  750.   }
  751.  
  752. void Verify_Messages()
  753.   {
  754.   MSG_NUMBER msg, firstMessage;
  755.   MSG_NUMBER total;     /* For stat keeping. */
  756.   extern struct mBuf mFile1;
  757.   if( !Mflag ) return;
  758.   fprintf(stderr, "Mulching...\n");
  759.   InitMsgBase();
  760.   startAt(msgfl, &mFile1, 0, 0);
  761.   getMessage(getMsgChar, FALSE, TRUE, TRUE);
  762.   firstMessage = atol(msgBuf.mbId);
  763.   Do_Message(&msgBuf);
  764.   msg = firstMessage -1;
  765.   total = 1;
  766.   while (msg != firstMessage)
  767.     {
  768.     total++;
  769.     getMessage(getMsgChar, FALSE, TRUE, TRUE);
  770.     Do_Message(&msgBuf);
  771.     msg = atol(msgBuf.mbId);
  772.  
  773.     }
  774.   Do_Room_Stats(total);
  775.  
  776.   }
  777. void Do_Message(MessageBuffer  *msg)
  778.   {
  779.   Process_Msg(msg);
  780.   if( MControl == 'A')
  781.     {
  782.     printf("\nMsg: %6d Sector ID: %6d Author:%s To:%s "
  783.     ,  msg->mbheadChar, msg->mbheadSector, msg->mbauth, msg->mbto);
  784.     printf("Name:%s ID:%s Room:%s",  msg->mboname,  msg->mborig,  msg->mbroom);
  785.     }
  786.   else
  787.     {
  788.     printf("Message %4d Sector ID: %5d Author:%16s",  msg->mbheadChar, msg->mbheadSector, msg->mbauth);
  789.     if( sfflag ) printf("\n");
  790.     printf(" Date:%8s Time:%8s Local Id:%10s",  msg->mbdate,  msg-> mbtime,  msg-> mbId);
  791.     if( sfflag ) printf("\n");
  792.     printf(" Human:%15s ID:%14s Room:%15s",  msg->mboname,  msg->mborig,  msg->mbroom);
  793.     if( sfflag ) printf("\n");
  794.     printf(" Origin:%s To:%s",  msg->mbsrcId,  msg->mbto);
  795.     if( sfflag ) printf("\n");
  796.     printf(" Route:%s", msg->mbaddr);
  797.     if( sfflag ) printf("\n");
  798.     printf(" OtherNet:%s",msg->mbOther);
  799.     if( sfflag ) printf("\n");
  800.     printf(" reply:%s Domain:%0s",msg->mbreply, msg->mbdomain);
  801.     };
  802.   printf("\n");
  803.   }
  804. /*
  805. * MsgLen()
  806. *
  807. * This function figures out the byte usage of the message.
  808. */
  809. int MsgLen(MessageBuffer  *msg)
  810.   {
  811.   return  (int) (       strlen(msg->mbtext)  + strlen(msg->mbauth) +
  812.   strlen(msg->mbdate)  + strlen(msg->mbtime) +
  813.   strlen(msg->mbId)    + strlen(msg->mboname) +
  814.   strlen(msg->mborig)  + strlen(msg->mbroom) +
  815.   strlen(msg->mbsrcId) + strlen(msg->mbto) +
  816.   strlen(msg->mbaddr)  + strlen(msg->mbOther) );
  817.  
  818.   }
  819. void Do_NetBuf_Data(int slot)
  820.   {
  821.   printf("\nSlot:%2d Node Name:%-22s  Node Id: %s\n",slot,netBuf.netName, netBuf.netId);
  822.   printf("Short Name:%c%c%c  Passwords: Our(%s) Their(%s)\n",
  823.   (isprint(netBuf.nbShort[0]) ? netBuf.nbShort[0] : '*'),
  824.   (isprint(netBuf.nbShort[1]) ? netBuf.nbShort[1] : '*'),
  825.   (isprint(netBuf.nbShort[2]) ? netBuf.nbShort[2] : '*'),
  826.   netBuf.OurPwd, netBuf.TheirPwd);
  827.   printf("baudCode:%d nbGen: %d access:%s\n",
  828.   (int)netBuf.baudCode, (int)netBuf.nbGen, netBuf.access);
  829.   printf("nbRoute:%d nbRouteGen:%d nbHiRouteInd: %d nbLastConnect: %x\n",
  830.   netBuf.nbRoute, netBuf.nbRouteGen, netBuf.nbHiRouteInd, netBuf.nbLastConnect);
  831.   Do_nflags(&netBuf.nbflags);
  832.   Do_Multi_Net_Data(netBuf.MemberNets);
  833.   Do_Shared_Room(netBuf.netRooms);
  834.  
  835.   }
  836.  
  837. void  Process_Other_Room_Data(int Index)
  838.   {
  839.   int i;
  840.   int count;
  841.   MSG_NUMBER msgNo;
  842.   getRoom(Index);
  843.   printf("Slot: %d %s\n ",Index, roomBuf.rbname);
  844.   printf("     rbgen:%d  rbFlIndex: %d ShareType:");
  845.   switch( roomBuf.rbShareType)
  846.     {
  847.     case             PEON: printf("PEON\n"); break;
  848.     case         REG_HOST: printf("REG_HOST\n"); break;
  849.     case         BACKBONE: printf("BACKBONE\n"); break;
  850.     case    PASS_BACKBONE: printf("PASSIVE\n"); break;
  851.     case  ACTIVE_BACKBONE: printf("ACTIVE\n"); break;
  852.     default:               printf("Unknown\n");
  853.     };
  854.   printf("Room Area:");
  855.   if (roomBuf.rbflags.ISDIR)
  856.     {
  857.     printf("%s\n", &roomBuf.rbArea);
  858.     }
  859.   else printf("No Directory\n");
  860.   Do_Boolean("Public            ",roomBuf.rbflags.PUBLIC,         FALSE);
  861.   Do_Boolean("Directory         ",roomBuf.rbflags.ISDIR,          FALSE);
  862.   Do_Boolean("Permanent         ",roomBuf.rbflags.PERMROOM,       TRUE);
  863.   Do_Boolean("Skipped           ",roomBuf.rbflags.SKIP,           FALSE);
  864.   Do_Boolean("Uploadable        ",roomBuf.rbflags.UPLOAD,         FALSE);
  865.   Do_Boolean("Downloadable      ",roomBuf.rbflags.DOWNLOAD,       TRUE);
  866.   Do_Boolean("Shared            ",roomBuf.rbflags.SHARED,         FALSE);
  867.   Do_Boolean("Archived          ",roomBuf.rbflags.ARCHIVE,        FALSE);
  868.   Do_Boolean("Anonymous         ",roomBuf.rbflags.ANON,           TRUE);
  869.   Do_Boolean("Net Downloadable  ",roomBuf.rbflags.NO_NET_DOWNLOAD,FALSE);
  870.   Do_Boolean("Invitational      ",roomBuf.rbflags.INVITE,         FALSE);
  871.   Do_Boolean("Automaticly Netted",roomBuf.rbflags.AUTO_NET,       TRUE);
  872.   Do_Boolean("All Users Netted  ",roomBuf.rbflags.ALL_NET,        FALSE);
  873.   Do_Boolean("Read Only         ",roomBuf.rbflags.READ_ONLY,      TRUE);
  874.  
  875.   count = 0;
  876.   for (i = 0;  i < MSGSPERRM;   i++)
  877.     {
  878.     msgNo = roomBuf.msg[i].rbmsgNo & S_MSG_MASK;
  879.     if (msgNo >= cfg.oldest) count++;
  880.     };
  881.   printf("There are %d messages in this room\n");
  882.   }
  883.